"use strict";
var core = require("../utils/core");
var util = require("./util");
var license = require("../utils/license");
var render = function() {
  var _vm = this;
  var _h = _vm.$createElement;
  var _c = _vm._self._c || _h;
  return _c("el-dialog", { ref: "modal", class: _vm.modalClass, style: _vm.dialogStyle, attrs: { "visible": _vm.modalVisible, "title": _vm.title, "width": _vm.width, "top": _vm.modalTop, "modal": _vm.modalMask, "modal-append-to-body": _vm.modalAppendToBody, "append-to-body": _vm.dialogAppendToBody, "lock-scroll": _vm.lockScroll, "custom-class": _vm.customClass, "close-on-click-modal": _vm.maskClosable, "close-on-press-escape": _vm.closeOnPressEscape, "show-close": _vm.showClose, "before-close": _vm.beforeClose, "center": _vm.center, "destroy-on-close": _vm.destroyOnClose }, on: { "update:visible": _vm.updateVisible, "open": _vm.onOpen, "opened": _vm.onOpened, "close": _vm.onClose, "closed": _vm.onClosed } }, [_vm._t("default"), _c("template", { slot: "footer" }, [_vm._t("footer")], 2), _c("template", { slot: "title" }, [_vm._t("title", function() {
    return [_c("span", { staticClass: "el-dialog__title" }, [_vm._v(_vm._s(_vm.title))])];
  }), _vm.maxable ? _c("button", { staticClass: "el-dialog__headerbtn ele-modal-icon-fullscreen", attrs: { "type": "button" }, on: { "click": function($event) {
    return _vm.toggleFullscreen();
  } } }, [_vm._t("maxIcon", function() {
    return [_c("i", { class: _vm.maxIconClass })];
  }, { "fullscreen": _vm.isFullscreen })], 2) : _vm._e()], 2)], 2);
};
var staticRenderFns = [];
function normalizeComponent(scriptExports, render2, staticRenderFns2, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
  var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
  if (render2) {
    options.render = render2;
    options.staticRenderFns = staticRenderFns2;
    options._compiled = true;
  }
  if (functionalTemplate) {
    options.functional = true;
  }
  if (scopeId) {
    options._scopeId = "data-v-" + scopeId;
  }
  var hook;
  if (moduleIdentifier) {
    hook = function(context) {
      context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
      if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
        context = __VUE_SSR_CONTEXT__;
      }
      if (injectStyles) {
        injectStyles.call(this, context);
      }
      if (context && context._registeredComponents) {
        context._registeredComponents.add(moduleIdentifier);
      }
    };
    options._ssrRegister = hook;
  } else if (injectStyles) {
    hook = shadowMode ? function() {
      injectStyles.call(this, (options.functional ? this.parent : this).$root.$options.shadowRoot);
    } : injectStyles;
  }
  if (hook) {
    if (options.functional) {
      options._injectStyles = hook;
      var originalRender = options.render;
      options.render = function renderWithStyleInjection(h, context) {
        hook.call(context);
        return originalRender(h, context);
      };
    } else {
      var existing = options.beforeCreate;
      options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
    }
  }
  return {
    exports: scriptExports,
    options
  };
}
const __vue2_script = {
  name: "EleModal",
  props: {
    movable: {
      type: Boolean,
      default: true
    },
    moveOut: Boolean,
    moveOutPositive: Boolean,
    resizable: [Boolean, String],
    maxable: Boolean,
    multiple: Boolean,
    fullscreen: Boolean,
    inner: Boolean,
    resetOnClose: {
      type: Boolean,
      default: true
    },
    centered: Boolean,
    maskKeepAlive: {
      type: Boolean,
      default: true
    },
    visible: Boolean,
    title: String,
    width: {
      type: String,
      default: "50%"
    },
    top: {
      type: String,
      default: "15vh"
    },
    modal: {
      type: Boolean,
      default: true
    },
    modalAppendToBody: {
      type: Boolean,
      default: true
    },
    appendToBody: Boolean,
    lockScroll: {
      type: Boolean,
      default: true
    },
    customClass: String,
    closeOnClickModal: {
      type: Boolean,
      default: true
    },
    closeOnPressEscape: {
      type: Boolean,
      default: true
    },
    showClose: {
      type: Boolean,
      default: true
    },
    beforeClose: Function,
    center: Boolean,
    destroyOnClose: Boolean
  },
  inject: {
    proLayout: {
      default: null
    }
  },
  data() {
    var _a;
    return {
      authenticated: license.checkLicense(),
      mobile: core.screenWidth() < 768,
      isFullscreen: (_a = this.fullscreen) != null ? _a : false,
      isActivated: true,
      parentEl: void 0,
      modalVisible: this.visible
    };
  },
  computed: {
    layoutData() {
      var _a;
      return (_a = this.proLayout) != null ? _a : {};
    },
    isMobile() {
      var _a;
      return (_a = this.layoutData.isMobile) != null ? _a : this.mobile;
    },
    collapse() {
      return this.layoutData.collapse;
    },
    sideNavCollapse() {
      return this.layoutData.sideNavCollapse;
    },
    isTopMenu() {
      return this.layoutData.isTopMenu;
    },
    isMixSideMenu() {
      return this.layoutData.isMixSideMenu;
    },
    bodyFullscreen() {
      return this.layoutData.bodyFullscreen;
    },
    contentFullscreen() {
      return this.layoutData.contentFullscreen;
    },
    showTabs() {
      return this.layoutData.showTabs;
    },
    haveSideMenuData() {
      return this.layoutData.haveSideMenuData;
    },
    modalClass() {
      const classes = [];
      if (!this.isMobile) {
        if (this.movable) {
          classes.push(util.movableClass);
        }
        if (this.moveOut) {
          classes.push(util.moveOutClass);
        }
        if (this.moveOutPositive) {
          classes.push(util.moveOutPositiveClass);
        }
        if (this.resizable) {
          classes.push(util.resizableClass);
          if (typeof this.resizable === "string") {
            classes.push(util.resizableClass + "-" + this.resizable);
          }
        }
      }
      if (this.multiple) {
        classes.push(util.multipleClass);
      }
      if (this.isFullscreen) {
        classes.push(util.fullscreenClass);
      }
      if (!this.visible) {
        classes.push(util.closedClass);
      }
      if (!this.isActivated && this.visible) {
        classes.push(util.hideClass);
      }
      if (this.inner) {
        classes.push(util.innerClass);
        if (this.modal) {
          classes.push(util.innerMaskClass);
        }
        if (this.collapse && !this.isTopMenu) {
          classes.push(util.collapseClass);
        }
        if (this.sideNavCollapse && this.isMixSideMenu && !this.isTopMenu) {
          classes.push(util.navCollapseClass);
        }
        if (this.bodyFullscreen) {
          classes.push(util.bodyFullscreenClass);
        }
        if (this.showTabs) {
          classes.push(util.showTabsClass);
        }
        if (this.isMixSideMenu && !this.isTopMenu) {
          classes.push(util.sideMixClass);
          if (!this.haveSideMenuData) {
            classes.push(util.sideMixSingleClass);
          }
        }
        if (this.isTopMenu) {
          classes.push(util.layoutTopClass);
        }
        if (this.bodyFullscreen && this.contentFullscreen) {
          classes.push(util.contentFullscreenClass);
        }
        if (this.isMobile) {
          classes.push(util.mobileClass);
        }
      }
      if (this.centered) {
        classes.push(util.centeredClass);
      }
      return classes.join(" ");
    },
    dialogStyle() {
      const width = typeof this.width === "number" ? `${this.width / 2}px` : `calc(${this.width} / 2)`;
      return {
        "--modal-centered-left": `calc(50% - ${width})`
      };
    },
    maxIconClass() {
      return [
        "el-dialog__close",
        "el-icon",
        this.isFullscreen ? "el-icon-_compress" : "el-icon-full-screen"
      ].join(" ");
    },
    modalMask() {
      if (this.multiple || this.inner) {
        return false;
      }
      return this.modal;
    },
    dialogAppendToBody() {
      return this.multiple ? false : this.appendToBody;
    },
    maskClosable() {
      return this.multiple ? false : this.closeOnClickModal;
    },
    modalTop() {
      return this.centered ? "0px" : this.top;
    }
  },
  mounted() {
    const wrapEl = this.getWrapEl();
    if (this.authenticated) {
      util.bindMovableEvent(wrapEl);
      util.bindResizableEvent(wrapEl);
      util.bindAutoSetTopEvent(wrapEl);
    }
    this.parentEl = wrapEl.parentNode;
    this.updateModalContainer();
  },
  methods: {
    getWrapEl() {
      return this.$refs.modal.$el;
    },
    updateVisible(visible) {
      this.$emit("update:visible", visible);
    },
    onOpen() {
      this.$emit("open");
    },
    onOpened() {
      this.$emit("opened");
    },
    onClose() {
      if (this.visible === this.modalVisible) {
        this.$emit("close");
      }
    },
    onClosed() {
      if (this.visible === this.modalVisible) {
        this.$emit("closed");
      }
    },
    toggleFullscreen(fullscreen) {
      if (typeof fullscreen === "undefined") {
        this.isFullscreen = !this.isFullscreen;
      } else {
        this.isFullscreen = fullscreen;
      }
      this.$emit("update:fullscreen", this.isFullscreen);
    },
    updateModalContainer() {
      const wrapEl = this.getWrapEl();
      if (this.multiple) {
        util.getModalContainer().appendChild(wrapEl);
      }
    }
  },
  activated() {
    this.isActivated = true;
    this.modalVisible = this.visible;
  },
  deactivated() {
    this.isActivated = false;
    if (this.modalMask) {
      if (!this.maskKeepAlive) {
        this.updateVisible(false);
      } else if (!this.destroyOnClose) {
        this.modalVisible = false;
      }
    }
  },
  watch: {
    fullscreen(fullscreen) {
      if (this.isFullscreen !== fullscreen) {
        this.isFullscreen = fullscreen;
      }
    },
    visible(visible) {
      this.modalVisible = visible;
      if (visible) {
        this.$nextTick(() => {
          const wrapEl = this.getWrapEl();
          if (this.resetOnClose) {
            util.resetModalStyle(wrapEl, this.width, this.modalTop);
          }
          util.setModalTop(wrapEl);
        });
        if (this.resetOnClose || this.destroyOnClose) {
          this.isFullscreen = this.fullscreen;
        }
      }
    }
  }
};
const __cssModules = {};
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
function __vue2_injectStyles(context) {
  for (let o in __cssModules) {
    this[o] = __cssModules[o];
  }
}
var index = /* @__PURE__ */ function() {
  return __component__.exports;
}();
module.exports = index;
